/**  
 *	VisualGroup JavaScript prototype Classes, version 0.1
 *  (c) 2008 Bill Vison <vison_ruan@126.com>
 *
 *
/*--------------------------------------------------------------------------*/
using("Vsg.Component");

Vsg.Component.AttentionBlockGrid = Ext.extend(Ext.grid.GridPanel,{
	
	defaultMethod:function($config) {
		// --- defind basic defined ---
		if ($config == null) {
			throw "Do not defined a basic config for object!";
		}

		var sm = new Ext.grid.CheckboxSelectionModel({
			singleSelect:false
		});
				
		var $_con = {
			height:"100%",
			iconCls:"icon-grid",
			viewConfig:{forceFit:true},
			maskDisabled:false,
        	loadMask: true, 			
			sm:sm,
			colModel:new Ext.grid.ColumnModel([
				sm,
				{
					header: "板块名称",
					width: 150,
					sortable: false,
					dataIndex: "description"
				},
				{
					header: "类 型",
					sortable: false, 
					dataIndex: "type"
				},
				{
					header: "开始日期",
					sortable: false, 
					dataIndex: "startDate"
				},
				{
					header: "周 期",
					width: 40,
					sortable: false,
					menuDisabled:true, 
					dataIndex: "cycle"
				}				
			])
		};


		try {
			
			// --- add top tool bar ----
	
			
			for (var $i in $config) {
				$_con[$i] = $config[$i];
			}
			
		} catch (e) {
			// -- catch default value defined ---
			alert(e);
		}
		return $_con;		
			
	},
	
	
	constructor:function($config) {
		
		var storeAutoLoad = true;
		var url = $config.url;
		if (url == null || url == undefined) {
			throw "[Vsg.Component.AttentionBlockGrid] 未定义 'url'";
			return;
		}

		var store = new Ext.data.JsonStore({
    		// store configs
    		autoLoad : storeAutoLoad,
    		url: url,
    		// reader configs
    		root: 'rows',
    		idProperty: 'id',  
    		fields: [
				{name:'description'},
				{name:'type'},
				{name:'startDate'},
				{name:'cycle'}
			]
		});
		var $attrs = this.defaultMethod($config);

		$attrs.store = store;
		if ($config.id) {
			$attrs.id = $config.id;
		}

		if ($config.title) {
			$attrs.title = $config.title;
		}

		Ext.applyIf(this, $attrs);
        
		Vsg.Component.AttentionBlockGrid.superclass.constructor.call(this, $attrs);
		
	}
});